<%-- 
    Document   : Shopping
    Created on : May 17, 2012, 1:36:13 PM
    Author     : Alex

    Our main window, where we buy the groceries!
--%>
<%@page import="beans.Customer"%>
<%@page import="store.ShopInventory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Shopping Page</title>
    </head>
    <body>
        <h1>Hello <%= Customer.getName() %>, Welcome to the Store</h1>
        <h2> Please put a Quantity Beside Each Item </h2>
        <br/>
        <%
          if (Integer.parseInt(request.getParameter("itemNumber"))
                  < ShopInventory.getNumberOfItems())
        %>
            <form action="<%= config.getInitParameter("nextPage") %>" 
                  method="POST">
                <%= ShopInventory.getNextItems(Integer.parseInt(
                request.getParameter("itemNumber")), 3) %>
                <input type="submit" value="Next" ><br>
            </form>
        <%
          if (Integer.parseInt(request.getParameter("itemNumber")) >= 
          ShopInventory.getNumberOfItems()) {
              // When we have gone through all of the items, check out
              String checkOutPage = config.getInitParameter("checkOutPage");
              // Redirect, rather than forward so that the back button works
              response.sendRedirect(checkOutPage);
          }
        %>
    </body>
</html>
